package practice1;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class P1003 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        Map<Integer,String> map =new HashMap<>();
        for(int i=1;i<=n;i++){
            int a=sc.nextInt();
            int b=sc.nextInt();     //左下角坐标(a,b)
            int x=sc.nextInt();
            int y=sc.nextInt();     //x,y轴的长度
            String info = a+","+b+","+x+","+y;
            map.put(i,info);
        }
        int x2 =sc.nextInt();
        int y2 =sc.nextInt();
        boolean flag = false;
        for(int i=n;i>=1;i--){
            String info = map.get(i);
            String[] strings = info.split(",");
            int a = Integer.parseInt(strings[0]);
            int b = Integer.parseInt(strings[1]);
            int x = Integer.parseInt(strings[2]);
            int y = Integer.parseInt(strings[3]);
            if((x2>=a && x2<=a+x) && (y2>=b && y2<=b+y)){
                System.out.println(i);
                flag = true;
                break;
            }
        }
        if(!flag){
            System.out.println(-1);
        }
    }
}
